-
Notifications
You must be signed in to change notification settings - Fork 0
Add bidirectional conversion between SQL files and @Sql annotations #383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…g invocation outside of the formatter functionality.
…files and Sql annotations.
…is applied to SQL generated by the action.
…ready exists when the action is executed.
…y after """, regardless of code style settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements bidirectional conversion functionality between SQL files and @SQL annotations in Doma DAO methods, enabling developers to seamlessly switch between inline SQL annotations and external SQL files.
- SQL annotation to file conversion: Converts @SQL, @select, @update, @insert, @delete, @BatchUpdate, @BatchInsert, @BatchDelete, and @script annotations to external SQL files with automatic formatting
- SQL file to annotation conversion: Converts external SQL files back to @SQL annotations with proper escaping and formatting
- Infrastructure improvements: New dedicated SQL formatter and comprehensive test coverage for both conversion directions
Reviewed Changes
Copilot reviewed 85 out of 85 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| New test data files | Expected output files for testing both conversion directions across different DAO annotation types |
| ConvertSqlFileToAnnotationActionTest.kt | Test cases for SQL file to @SQL annotation conversion functionality |
| ConvertSqlAnnotationToFileActionTest.kt | Test cases for @SQL annotation to SQL file conversion functionality |
| DomaToolsBundle*.properties | Internationalized messages for the new conversion actions |
| Intention descriptions | HTML documentation for the new intention actions |
| plugin.xml | Plugin registration for the two new intention actions |
| DaoInjectionSqlVisitor.kt | Refactored to use the new dedicated InjectionSqlFormatter |
| SqlInjectionPostProcessor.kt | Updated to use the new InjectionSqlFormatter |
| InjectionSqlFormatter.kt | New dedicated SQL formatter for injection contexts |
| PsiDaoMethod.kt | Enhanced to handle SQL file deletion when overwriting existing files |
| SqlAnnotationConverter.kt | Core conversion logic handling both directions with SQL formatting |
| ConvertSqlFileToAnnotationAction.kt | Intention action for converting SQL files to @SQL annotations |
| ConvertSqlAnnotationToFileAction.kt | Intention action for converting @SQL annotations to SQL files |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
src/main/kotlin/org/domaframework/doma/intellij/action/dao/SqlAnnotationConverter.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/processor/InjectionSqlFormatter.kt
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/action/dao/SqlAnnotationConverter.kt
Show resolved
Hide resolved
…generating an annotation from a file.
6fd2bba to
41dbfa2
Compare
Summary
This PR implements bidirectional conversion functionality between SQL files and @SQL annotations in Doma DAO methods, allowing developers to seamlessly switch between these
two SQL definition approaches.
Changes
New Features
SQL Annotation to File Conversion (
ConvertSqlAnnotationToFileAction)SQL File to Annotation Conversion (
ConvertSqlFileToAnnotationAction)SQL Annotation Converter Utility (
SqlAnnotationConverter)Infrastructure Improvements
InjectionSqlFormatter)Testing
� Generated with Claude Code
Co-Authored-By: Claude [email protected]